package cn.jiedanba.cacert.caadmin.controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.jiedanba.cacert.admin.service.SysUserService;
import cn.jiedanba.cacert.admin.vo.LoginVo;
import cn.jiedanba.cacert.common.result.ResponseResult;

@Controller
public class LoginController {

	@Resource
	private SysUserService sysUserService;

	/**
	 * 登录界面
	 * 
	 * @param request
	 * @param response
	 * @return
	 */
	@GetMapping("/login")
	public String login(HttpServletRequest request, HttpServletResponse response) {
		return "login";
	}

	/**
	 * 登录
	 * 
	 * @param login
	 * @return
	 */
	@PostMapping("/login")
	@ResponseBody
	public ResponseResult login(@Valid LoginVo login, HttpServletRequest request) {
		return sysUserService.login(login, request);
	}

}
